import 'package:feature_main/ui/mvi_home_tab_page.dart';
import 'package:feature_projects/projects/projects_tab_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get_it/get_it.dart';
import 'package:wanandroid_client/page/main/main_page_controllers.dart';
import 'package:wanandroid_client/page/main/test_pages.dart';

import 'bottom_navigation.dart';

class MainPage extends StatelessWidget {
  const MainPage({super.key});

  @override
  Widget build(BuildContext context) => GetBuilder<MainPageController>(
    builder: (controller) => Obx(
      () => Scaffold(
        extendBody: true,
        resizeToAvoidBottomInset: false,
        bottomNavigationBar: BottomNavigation(
          navItems: [
            BottomNavItem(
              text: "首页",
              iconPath: 'assets/main/nav_icon_home.png',
            ),
            BottomNavItem(
              text: "项目",
              iconPath: 'assets/main/nav_icon_project.png',
            ),
            BottomNavItem(
              text: "发现",
              iconPath: 'assets/main/nav_icon_discovery.png',
            ),
          ],
          onTap: (idx) {
            controller.onTabChanges(idx);
          },
          selectedIndex: controller.currentSelectedTabIndex,
        ),
        body: PageView(
          physics: const NeverScrollableScrollPhysics(),
          controller: controller.pageController,
          onPageChanged: controller.onPageIndexChanged,
          // children: [const HomeTabPage(), TestPage2(), TestPage3()],
          children: [const MviHomeTabPage(), ProjectsPage(config: GetIt.I.get()), TestPage3()],
        ),
      ),
    ),
  );
}
